﻿// ===============================================================================
// XCI.NET 西安交通信息WinForm开发框架 2018 版权所有
// ===============================================================================
using System.ComponentModel;
using System.IO;
using DevExpress.Utils;
using XCI.Core;
using XCI.Helper;

namespace XCI.Windows.Plugin.GridSetting.UI
{
    [ToolboxItem(false)]
    public partial class GridTemplate : BaseGridTemplate
    {
        public GridTemplate()
        {
            InitializeComponent();
        }

        private GridSettingPlugin Plugin { get; set; }

        public void Initialize(GridSettingPlugin uiplugin)
        {
            this.Plugin = uiplugin;
            Initialize();
        }

        protected override string GetId()
        {
            return Plugin.Id;
        }

        protected override string GetSetting()
        {
            return Plugin.GetSetting();
        }

        protected override BoolMessage ApplySetting(string data)
        {
            if (data != null)
            {
                var view = Plugin.View;
                view.Columns.Clear();
                view.FormatConditions.Clear();
                view.Appearance.Reset();
                Plugin.SetSetting(data);
                return BoolMessage.True;
            }
            return new BoolMessage(false, "表格配置数据为空,无法应用配置");
        }
        
    }
}
